Apparatus and method for accelerating Java translation

ABSTRACT

An apparatus and method for accelerating Java translation are provided. The apparatus includes a lookup table which stores an lookup table having arrangements of bytecodes and native codes corresponding to the bytecodes, a decoder which generates pointer to the native code corresponding to the feed bytecode in the lookup table, a parameterized bytecode processing unit which detects parameterized bytecode among the feed bytecode, and generating pointer to native code required for constant embedding in the lookup table, a constant embedding unit which embeds constants into the native code with the pointer generated by the parameterized bytecode processing unit, and a native code buffer which stores the native code generated by the decoder or the constant embedding unit.

CROSS-REFERENCE TO RELATED APPLICATION

This application claims priority from Korean Patent Application No.10-2007-0054663 filed on Jun. 4, 2007 in the Korean IntellectualProperty Office, the disclosure of which is incorporated herein byreference in its entirety.

BACKGROUND OF THE INVENTION

1. Field of the Invention

Apparatuses and methods consistent with the present invention relate toaccelerating Java translation, by which optimized bytecode can begenerated.

2. Description of the Related Art

Java is an object-orientated programming language developed by SunMicrosystems, Inc., which has several significant advantages overrelated art programming languages, including platform independence,sandbox model security and code compaction. Java code is small, simpleand portable across platforms and operating systems.

In related art programming languages, the source code of a program issent to a compiler which translates the program into machine code orprocessor instructions, which include native instructions. For example,an instruction compiled for the x86 system can only be executed by thex86 system only.

However, the Java compiler takes a Java program and generates bytecodes.Bytecodes are instructions that look like machine code, but are notspecific to any processor. To execute Java bytecode, a Java VirtualMachine is necessary.

The Java Virtual Machine interprets Java bytecode and converts it toequivalent native code. Since bytecode is not specific to any processor,programs in bytecode can run on any architecture as long the JavaVirtual Machine is available.

One disadvantage of Java bytecode is a slow execution speed.System-specific programs that run directly on the hardware for whichthey are compiled run significantly faster than Java bytecode, whichmust be processed by the Java Virtual Machine. The processor must bothconvert the Java bytecodes into native instructions in the Java VirtualMachine and execute the native instructions.

There are several techniques for improving the execution speed of Javabytecode; one is to speed up the Java Virtual Machine by a techniquecalled “Just-in-Time” (JIT) compiling, which, however has disadvantagesof a slow execution speed and a JIT compile overhead.

To overcome these disadvantages, the use of a Java hardware acceleratorhas been proposed. The Java hardware accelerator converts Java bytecodesinto native codes using a lookup table. That is, the Java hardwareaccelerator attempts to speed up the execution speed by converting theJava bytecode into the native code stored in the lookup table.

Even with the Java hardware accelerator, there still exist problems ofadditional memory usage and power consumption. Accordingly, it isdesirable to provide a technique capable of achieving the minimum memoryusage and low power consumption. What is needed, therefore, is a methodfor optimizing the process of converting bytecode into native code.

SUMMARY OF THE INVENTION

Exemplary embodiments of the present invention overcome the abovedisadvantages and other disadvantages not described above. Also, thepresent invention is not required to overcome the disadvantagesdescribed above, and an exemplary embodiment of the present inventionmay not overcome any of the problems described above.

The present invention provides an apparatus and method for acceleratingJava translation, by which generate native codes optimized to bytecodescan be generated.

According to an aspect of the present invention, there is provided anapparatus for accelerating Java translation, the apparatus including anlookup table having arrangements of bytecodes and native codescorresponding to the bytecodes, a decoder generating pointer to thenative code corresponding to the feed bytecode in the lookup table, aparameterized bytecode processing unit detecting parameterized bytecodeamong the feed bytecode, and generating pointer to native code requiredfor constant embedding in the lookup table, a constant embedding unitembedding constants into the native code with the pointer generated bythe parameterized bytecode processing unit, and a native code bufferstoring the native code generated by the decoder or the constantembedding unit.

According to another aspect of the present invention, there is provideda method for accelerating Java translation, the method includingdetermining whether feed bytecode is parameterized bytecode, invokingnative code required for constant embedding, the native codecorresponding to the parameterized bytecode, detecting key instructionsfrom the invoked native code, and embedding constants into theidentified key instructions.

BRIEF DESCRIPTION OF THE DRAWINGS

The above and other aspects of the present invention will becomeapparent by describing in detail exemplary embodiments thereof withreference to the attached drawings in which:

FIG. 1 is a diagram illustrating an apparatus for accelerating Javatranslation according to an exemplary embodiment of the parentinvention;

FIG. 2 is a flow diagram illustrating a method of accelerating Javatranslation according to an exemplary embodiment of the parentinvention;

FIG. 3 is a flow diagram illustrating a process of analyzing feedbytecode in the method for accelerating Java translation according to anexemplary embodiment of the parent invention;

FIG. 4 is a flow diagram illustrating a process of invoking native codeby identifying key instructions from parameterized bytecode in themethod for accelerating Java translation according to an exemplaryembodiment of the parent invention; and

FIG. 5 is a flow diagram illustrating a process of embedding constantsinto the invoked native code in the method of accelerating Javatranslation according to an exemplary embodiment of the parentinvention.

DETAILED DESCRIPTION OF EXEMPLARY EMBODIMENTS OF THE INVENTION

Advantages and features of the present invention and methods ofaccomplishing the same may be understood more readily by reference tothe following detailed description of exemplary embodiments and theaccompanying drawings. The present invention may, however, be embodiedin many different forms and should not be construed as being limited tothe exemplary embodiments set forth herein. Rather, these exemplaryembodiments are provided so that this disclosure will be thorough andcomplete and will fully convey the concept of the invention to thoseskilled in the art, and the present invention will only be defined bythe appended claims. Like reference numerals refer to like elementsthroughout the specification.

An apparatus and method for accelerating Java translation according tothe present invention will be described hereinafter with reference toflowchart illustrations of methods according to exemplary embodiments ofthe invention.

It will be understood that each block of the flowchart illustrations,and combinations of blocks in the flowchart illustrations, can beimplemented by computer program instructions. These computer programinstructions can be provided to a processor of a general purposecomputer, special purpose computer, or other programmable dataprocessing apparatus to create means for implementing the functionsspecified in the flowchart block or blocks.

These computer program instructions may also be stored in a computerusable or computer-readable memory that can direct a computer or otherprogrammable data processing apparatus to function in a particularmanner, such that the instructions implement the function specified inthe flowchart block or blocks.

The computer program instructions may also be loaded into a computer orother programmable data processing apparatus to cause a series ofoperational steps to be performed on the computer or other programmableapparatus to produce a computer implemented process for implementing thefunctions specified in the flowchart block or blocks.

In addition, each block may represent a module, a segment, or a portionof code, which may comprise one or more executable instructions forimplementing the specified logical functions. It should also be notedthat in other implementations, the functions noted in the blocks mayoccur out of the order noted or in different configurations of hardwareand software. For example, two blocks shown in succession may, in fact,be executed substantially concurrently, or the blocks may sometimes beexecuted in reverse order, depending on the functionality involved.

For a better understanding of the present invention, the followingincludes definitions of selected terms employed in the specification.

Bytecode is a compiled form of a Java program. Once a Java program isconverted into a bytecode, the Java program can be transmitted via anetwork or executed by a Java virtual machine.

Native code is a machine language that is executed on a specificplatform. The native code is converted from bytecode by a virtualmachine.

Parameterized bytecode is bytecode having a parameter value. That is, abytecode executed depending on a specific value.

A key instruction is a native instruction into which a constantcorresponding to the parameter value is to be embedded in a set ofnative code corresponding to parameterized bytecode.

FIG. 1 is a diagram illustrating an apparatus for accelerating Javatranslation according to an exemplary embodiment of the presentinvention.

A lookup table unit 110 stores a lookup table including arrangements ofbytecodes and native codes corresponding to the bytecodes. The nativecodes may differ depending on a central processing unit (CPU) used andthe native codes corresponding to the bytecodes constitute a set of oneor more native instructions.

The lookup table stored in the lookup table unit 110 is used for adecoder 120 or a parameterized bytecode processing unit 130 to analyzenative code corresponding to feed bytecode.

Since the lookup table 110 does not store all bytecodes, the decoder 120preferably, but not necessarily, determines whether feed bytecode existsin the lookup table 110.

The lookup table unit 110 stores information about key instructions,that is, native instructions into which constants are embedded. Theinformation about the stored key instructions is used for a constantembedding unit 140 to identify the key instructions from the nativeinstructions.

Preferably, but not necessarily, the lookup table unit 110 stores maskpattern of key instructions. The stored mask pattern of key instructionsis used to identify constant embedding locations in the constantembedding unit 140 embedding constants into the native code.

The decoder 120 generates a pointer to the native code corresponding tothe feed bytecode in the lookup table unit 110. The pointer generated inthe lookup table unit 110 is useful for extracting the nativeinstruction set from the lookup table unit 110.

The decoder 120 determines whether the feed bytecode exists in thenative code buffer 150. If the feed bytecode exists in the native codebuffer 150, the corresponding native code is returned to the CPU,thereby increasing the processing speed.

In addition, the decoder 120 determines whether the feed bytecode existsin the lookup table unit 110. The lookup table stored in the lookuptable unit 110 does not include all native codes corresponding to thefeed bytecode. Thus, if the feed bytecode does not exist in the lookuptable, a software interpreter 160 interprets the bytecode.

The parameterized bytecode processing unit 130 may be incorporated intothe decoder 120.

The parameterized bytecode processing unit 130 detects parameterizedbytecode. If feed bytecode is parameterized bytecode, the parameterizedbytecode processing unit 130 generates a pointer to native code intowhich constants are embedded in the lookup table 110. That is, theparameterized bytecode processing unit 130 invokes native instructionscorresponding to constant versions of the bytecode. Here, theparameterized bytecode is not converted into native code havingparameter values but into native code having fixed values.

Preferably, but not necessarily, the parameterized bytecode processingunit 130 stores a list of parameterized bytecode.

An example of processing a Java bytecode implemented in an ARM CPU isdescribed in the following. The Java bytecode “ILOAD 10” means thatILOAD needs to load a value stored in a local variable 10 of the stack.Conventionally, in a case where ILOAD 10, for example, is feed, a nativecode corresponding to ILOAD is generated and a local variable address iscomputed.

The conventional native code corresponding to ILOAD is as follows.

LDRB reg1,[reg2],#offset

LDR reg1,[reg2+reg3 shift #n]

STR reg1,[reg2+offset]

In contrast, since the inventive Java bytecode “ILOAD 10” is aparameterized bytecode, the parameterized bytecode processing unit 130generates a pointer necessary in embedding constants into the nativecode. That is, for ILOAD 10, a native instruction corresponding toILOAD_(—)0 is invoked.

Native code corresponding to ILOAD_(—)0, according to the presentinvention, is as follows.

LDR r0,[VM_lp,#0]

STR r0,[VM_sp,#4]!

Compared to the conventional case, according to the present invention,the number of native instructions converted from bytecode can bereduced, that is, from three (3) to two (2), suggesting that memoryusage is reduced and the execution speed is accelerated.

The parameterized bytecode processing unit 130 analyzes a parametervalue of the parameterized bytecode. The parameter value of theparameterized bytecode should be suitable for an immediate field in anative instruction. In this example, since each address has anincremental of 4, the number of available bits in the immediate fieldmay be read as: 9−2=7. In this way, only when the parameter value issmaller than 128 is it encoded as an immediate operand. That is, forILOAD 10, since the parameter value, i.e., 10, is smaller than 128, anative instruction corresponding to ILOAD_(—)0 is invoked.

If the parameter value is not suitable for an immediate field in anative instruction, the parameterized bytecode processing unit 130generates a pointer required for embedding constants into the nativecode according to the conventional manner.

The constant embedding unit 140 embeds constants into the native codewith the pointer generated by the parameterized bytecode processing unit130. Here, the embedded constants are values corresponding to parametervalues input at the ends of the native code with the pointer. That is,the parameter value of the bytecode is encoded into immediate field ofthe native code.

The constant embedding unit 140 preferably, but not necessarily,performs a function of identifying key instructions using constants fromnon-key instructions among the native instructions. Native codeconstitutes a set of one or more native instructions with a pointergenerated thereat, and the constant embedding unit 140 identifiesconstant embedded key instructions from the one or more nativeinstructions. Information about key instructions is preferably, but notnecessarily, stored in the lookup table 110.

In the above-described example, native instruction codes correspondingto ILOAD_(—)0 are as follows.

LDR r0,[VM_lp,#0]

STR r0,[VM_sp,#4]!

In this example, the key instruction is LDR r0, [VM_lp,#0]. Accordingly,when a constant corresponding to the parameter value, i.e., 10, isembedded into the key instruction, the key instruction with theconstant, i.e., 10, embedded therein reads as:

LDR r0,[VM_lp,#40]

STR r0,[VM_sp,#4]!

As confirmed from the following, the same native code as the native codeconventionally converted from ILOAD 10 is obtained according to thepresent invention.

LDRB r0,[VM_ip],#1

LDR r0,[VM_lp,r0,LSL #2]

STR r0,[VM_sp,#4]!

The comparison results of conversion processes according to theconventional manner and the present invention show that while using thesame procedure, the present invention advantageously reduces the numberof native instructions, e.g., two (2) from three (3) in the case of theconventional manner. Therefore, the present invention reduces the amountof memory used, and increases the translation speed.

In addition, it is possible to prevent native code corresponding toILOAD_(—)1, ILOAD_(—)2, and ILOAD_(—)3 from being stored in the lookuptable unit 110. These ILOADs can be generated at ILOAD_(—)0. In such amanner, a storage space for ILOAD_(—)1, ILOAD_(—)2, and ILOAD_(—)3 canbe saved, so that additional storage space for other bytecodes can besecured.

Preferably, but not necessarily, the constant embedding unit 140 readsthe mask pattern of the key instructions stored in the lookup table unit110 for constant embedding. In most cases, immediate fields are fixedlocations of the key instructions. In few cases, however, in which animmediate field is not at a fixed location of a key instruction, acomplicated procedure may be involved. Accordingly, the mask pattern ofkey instructions are stored in the lookup table unit 110, and theconstant embedding unit 140 reads the mask pattern from the lookup tableunit 110 for reference in constant embedding.

The native code buffer 150 stores the native code generated by thedecoder 120 or the constant embedding unit 140. The native code buffer150 stores the native code and supplies the same to the CPU.

The native code buffer 150 preferably, but not necessarily, storesbytecode feed together with the native code. In the case where the feedbytecode exists in the native code buffer 150, the corresponding nativecode is returned to the CPU as per request by the decoder 120.

Here, various components of the Java translation accelerating apparatusaccording to the present invention may be implemented as, but are notlimited to, software, hardware or firmware. Each component mayadvantageously be configured to reside on an addressable storage mediumand configured to be executed on one or more processors. Thefunctionality provided for in the components may be combined into fewercomponents or further separated into additional components.

In an alternative exemplary embodiment, the apparatus for acceleratingJava translation may be incorporated into the CPU.

FIG. 2 is a flow diagram illustrating a method of accelerating Javatranslation according to an exemplary embodiment of the parentinvention.

Bytecode to be converted is feed from the CPU into the decoder 120 inoperation S210.

Then, the decoder 120 analyzes the feed bytecode in operation S220.

After analyzing the feed bytecode, the parameterized bytecode processingunit 130 detects parameterized bytecode from non-parameterized bytecode,and invokes native code in operation S230.

Thereafter, the constant embedding unit 140 embeds constants into thenative code in operation S240.

In operation S250, the native code buffer 150 stores the native codegenerated by the decoder 120 or the constant embedding unit 140. Thenative code buffer 150 preferably, but not necessarily, stores thebytecode feed together with the native code.

The native code buffer 150 sends the native code stored therein back tothe CPU in operation S260.

The method for accelerating Java translation according to the parentinvention will now be described in greater detail with reference toFIGS. 3 through 5.

FIG. 3 is a flow diagram illustrating a process of analyzing feedbytecode in the method for accelerating Java translation according to anexemplary embodiment of the present invention.

In operation S310, the decoder 120 determines whether the feed bytecodeexists in the native code buffer 150. If the feed bytecode exists in thenative code buffer 150, the procedure goes to operation S260 to returnthe corresponding native code to the CPU, thereby improving theprocessing speed.

In operation S320, the decoder 120 determines whether the feed bytecodeexists in the lookup table unit 110. If the feed bytecode exists in thelookup table unit 110, the procedure goes to operation S230. The lookuptable unit 110 does not include native codes for all the bytecodes.Accordingly, if the feed bytecode does not exist in the lookup tableunit 110, the software interpreter 160 interprets the bytecode inoperation S330.

FIG. 4 is a flow diagram illustrating a process of invoking native codeby detecting parameterized bytecode in the method for accelerating Javatranslation according to an exemplary embodiment of the parentinvention.

The parameterized bytecode processing unit 130 determines whether thefeed bytecode is to be parameterized bytecode in operation S410. Theparameterized bytecode processing unit 130 detects parameterizedbytecode by referring to a list of the parameterized bytecode stored inthe lookup table unit 110.

If the feed bytecode is not parameterized bytecode, a pointer to nativecode converted from the feed bytecode stored in the lookup table unit110 is generated by the decoder 120. In operation S420, the native codecorresponding to the feed bytecode is invoked.

The parameterized bytecode processing unit 130 analyzes parameter valuesof the parameterized bytecode and determines whether the parameterizedbytecode is suitable for immediate fields in the native instructions inoperation S430.

If the parameterized bytecode is not suitable for immediate fields inthe native instructions, a pointer to native code corresponding to thefeed bytecode is generated by the parameterized bytecode processing unit130 and the procedure goes to operation S420 to invoke the native codecorresponding to the feed bytecode.

The parameterized bytecode processing unit 130 generates a pointer tothe native code that can be used for embedding constant from lookuptable unit 110, and invokes the native code corresponding to theparameterized bytecode in operation S440. That is, the parameterizedbytecode processing unit 130 invokes the native code corresponding toconstant versions of the bytecode. The parameterized bytecode is notconverted into native code having parameter values but into native codehaving fixed values.

FIG. 5 is a flow diagram illustrating a process of embedding constantsinto the invoked native code in the method for accelerating Javatranslation according to an exemplary embodiment of the parentinvention.

The constant embedding unit 140 identifies key instructions usingconstants from the invoked native code in operation S510. The constantembedding unit 140 reads information about the key instructions from thelookup table unit 110 for reference in constant embedding. Since thenative code having a pointer constitute a set of one or more nativeinstructions, the key instructions with constants embedded therein canbe identified from the native code without constants.

The constant embedding unit 140 loads the mask pattern of the keyinstructions stored in the lookup table unit 110 in operation S520. Inmost cases, immediate fields are fixed locations. In few cases where animmediate field is not at a fixed location, however, a complicatedprocedure may be necessary. In this regard, the mask pattern of the keyinstructions is stored in the lookup table unit 110 so that the constantembedding unit 140 reads the mask pattern from the lookup table unit 110for reference in constant embedding. The constant embedding unit 140embeds constants into the key instructions in operation S530. Here, theembedded constants are values corresponding to the parameter valuesinput at the ends of the native code with the pointer generated thereat.That is, the parameter value of the bytecode is encoded into theimmediate field of the native code.

The content of the present invention can be applied to not only the Javalanguage but also other interpreter languages or virtual machinelanguages.

The apparatus and method for accelerating Java translation according tothe exemplary embodiments of the present invention may provide one ormore the following advantages.

First, memory usage can be reduced by generating native code optimizedto parameterized bytecode.

Second, translation speed can be accelerated by generating native codeoptimized to parameterized bytecode.

Third, storage space can be reduced by reducing the number of nativecodes stored in a lookup table.

The effects of the present invention should not be limited to theforegoing description, and additional effects and advantages of theinvention will be made more apparent to those skilled in the art fromthe spirit and scope of the invention as defined by the appended claims.

While the present invention has been particularly shown and describedwith reference to exemplary embodiments thereof, it will be understoodby those of ordinary skill in the art that various changes in form anddetails may be made therein without departing from the spirit and scopeof the present invention as defined by the following claims. It istherefore desired that the present exemplary embodiments be consideredin all respects as illustrative and not restrictive, reference beingmade to the appended claims rather than the foregoing description toindicate the scope of the invention.

1. An apparatus for accelerating Java translation, the apparatuscomprising: a lookup table unit which stores a lookup table includingarrangements of bytecodes and native codes corresponding to thebytecodes; a decoder which generates a pointer to the native codecorresponding to the feed bytecode in the lookup table; a parameterizedbytecode processing unit which detects parameterized bytecode among thefeed bytecode, and generates a pointer to native code required forconstant embedding in the lookup table; a constant embedding unit whichembeds constants into the native code with the pointer generated by theparameterized bytecode processing unit; and a native code buffer whichstores native code generated by the decoder or the constant embeddingunit.
 2. The apparatus of claim 1, wherein the parameterized bytecodeprocessing unit stores a list of parameterized bytecode.
 3. Theapparatus of claim 1, wherein the parameterized bytecode processing unitanalyzes parameter values of the bytecode.
 4. The apparatus of claim 1,wherein the constant embedding unit identifies key instructions usingconstants from non-key instructions among native instructions.
 5. Theapparatus of claim 1, wherein the constant embedding unit embedsconstants into key instructions by reading a mask pattern of the keyinstructions stored in the lookup table unit.
 6. The apparatus of claim1, wherein the lookup table unit stores information about keyinstructions.
 7. The apparatus of claim 1, wherein the lookup table unitstores a mask pattern of key instructions.
 8. The apparatus of claim 1,wherein the decoder determines whether the feed bytecode exists in thelookup table.
 9. The apparatus of claim 1, wherein the native codebuffer stores the bytecode feed together with the generated native code,and the decoder determines whether the feed bytecode exists in thenative code buffer.
 10. The apparatus according to claim 1, wherein theembedded constants are values corresponding to parameter values input atends of the native code with the pointer.